#!/bin/bash
# Copyright (C) 2024-2025 KoudaiPC Computer Technologies Co., Ltd.
# script name: huangdi-host-prepare-bootstrap-tgz.sh
# author: david921518@qq.com

# 1. Make work dir
rm -rf ./bootstrap/

# 2. Copy target scripts to mounted point
cp -af ../bootstrap ./
rm -rf ./bootstrap/preinstall/*.ipk
chown root:root ./bootstrap/ -R

# 3. Make archieve
rm -f bootstrap.tgz
tar -zcf bootstrap.tgz bootstrap/

# 4. Generate MD5 file
rm -f bootstrap.tgz.md5
md5sum bootstrap.tgz >bootstrap.tgz.md5

# 5. Generate SHA256 file
rm -f bootstrap.tgz.sha256
sha256sum bootstrap.tgz >bootstrap.tgz.sha256

# 6. Generate SHA512 file
rm -f bootstrap.tgz.sha512
sha512sum bootstrap.tgz >bootstrap.tgz.sha512

# 7. Move to parent dir
mv -f bootstrap.tgz ../
mv -f bootstrap.tgz.md5 ../
mv -f bootstrap.tgz.sha256 ../
mv -f bootstrap.tgz.sha512 ../

# 8. Remove work dir
rm -rf ./bootstrap/

